\documentclass{article}
\usepackage{booktabs}
\usepackage[margin=1in]{geometry}
\usepackage{Sweave}
\usepackage{setspace}
\usepackage{amsmath,amsthm}


\pdfpagewidth 8.5in
\pdfpageheight 11in
\setkeys{Gin}{width=\textwidth}
\title{Using Only Weibull}
\author{ }

\begin{document}

\maketitle
\pagebreak

<<echo=False>>=
exp1 <- read.table(file="weibull10_noed_nohet_maxt50.txt", header=TRUE)
exp2 <- read.table(file="weibull08_noed_nohet_maxt50.txt", header=TRUE)
exp3 <- read.table(file="weibull12_noed_nohet_maxt50.txt", header=TRUE)

mean1 <- round(mean(exp1$eventcount),3)
mean2 <- round(mean(exp2$eventcount),3)
mean3 <- round(mean(exp3$eventcount),3)

cens1 <- round(mean(exp1$censrate),3)
cens2 <- round(mean(exp2$censrate),3)
cens3 <- round(mean(exp3$censrate),3)

beta11 <- round(mean(exp1$betafrailgap),3)
beta12 <- round(mean(exp1$betafrailelapse),3)
beta13 <- round(mean(exp1$betaag),3)
beta14 <- round(mean(exp1$betacondgap),3)
beta15 <- round(mean(exp1$betacondelapse),3)

sd11 <- round(sd(exp1$betafrailgap), 3)
sd12 <- round(sd(exp1$betafrailelapse), 3)
sd13 <- round(sd(exp1$betaag), 3)
sd14 <- round(sd(exp1$betacondgap), 3)
sd15 <- round(sd(exp1$betacondelapse), 3)

se11 <- round(mean(exp1$stderfrailgap),3)
se12 <- round(mean(exp1$stderfrailelapse),3)
se13 <- round(mean(exp1$stderag),3)
se14 <- round(mean(exp1$stdercondgap),3)
se15 <- round(mean(exp1$stdercondelapse),3)

test11 <- ifelse((exp1$betafrailgap-1.96*exp1$stderfrailgap) <= -1 & -1 <= (exp1$betafrailgap+1.96*exp1$stderfrailgap), 1, 0)
test12 <- ifelse((exp1$betafrailelapse-1.96*exp1$stderfrailelapse) <= -1 & -1 <= (exp1$betafrailelapse+1.96*exp1$stderfrailelapse) , 1, 0)
test13 <- ifelse((exp1$betaag-1.96*exp1$stderag) <= -1 & -1 <= (exp1$betaag+1.96*exp1$stderag) , 1, 0)
test14 <- ifelse((exp1$betacondgap-1.96*exp1$stdercondgap) <= -1 & -1 <= (exp1$betacondgap+1.96*exp1$stdercondgap) , 1, 0)
test15 <- ifelse((exp1$betacondelapse-1.96*exp1$stdercondelapse) <= -1 & -1 <= (exp1$betacondelapse+1.96*exp1$stdercondelapse), 1, 0)
cr11 <- round(mean(test11),3)
cr12 <- round(mean(test12),3)
cr13 <- round(mean(test13),3)
cr14 <- round(mean(test14),3)
cr15 <- round(mean(test15),3)
theta11 <- round(mean(exp1$thetafrailgap),3)
theta12 <- round(mean(exp1$thetafrailelapse),3)
thetatest11 <- ifelse(exp1$thetapvalfrailgap <= .050, 1,0) 
thetatest12 <- ifelse(exp1$thetapvalfrailelapse <= .050, 1,0) 
rr11 <- round(mean(thetatest11),3)
rr12 <- round(mean(thetatest12),3)

beta21 <- round(mean(exp2$betafrailgap),3)
beta22 <- round(mean(exp2$betafrailelapse),3)
beta23 <- round(mean(exp2$betaag),3)
beta24 <- round(mean(exp2$betacondgap),3)
beta25 <- round(mean(exp2$betacondelapse),3)
sd21 <- round(sd(exp2$betafrailgap),3)
sd22 <- round(sd(exp2$betafrailelapse),3)
sd23 <- round(sd(exp2$betaag),3)
sd24 <- round(sd(exp2$betacondgap),3)
sd25 <- round(sd(exp2$betacondelapse),3)
se21 <- round(mean(exp2$stderfrailgap),3)
se22 <- round(mean(exp2$stderfrailelapse),3)
se23 <- round(mean(exp2$stderag),3)
se24 <- round(mean(exp2$stdercondgap),3)
se25 <- round(mean(exp2$stdercondelapse),3)
test21 <- ifelse((exp2$betafrailgap-1.96*exp2$stderfrailgap) <= -1 & -1 <= (exp2$betafrailgap+1.96*exp2$stderfrailgap), 1, 0)
test22 <- ifelse((exp2$betafrailelapse-1.96*exp2$stderfrailelapse) <= -1 & -1 <= (exp2$betafrailelapse+1.96*exp2$stderfrailelapse) , 1, 0)
test23 <- ifelse((exp2$betaag-1.96*exp2$stderag) <= -1 & -1 <= (exp2$betaag+1.96*exp2$stderag) , 1, 0)
test24 <- ifelse((exp2$betacondgap-1.96*exp2$stdercondgap) <= -1 & -1 <= (exp2$betacondgap+1.96*exp2$stdercondgap) , 1, 0)
test25 <- ifelse((exp2$betacondelapse-1.96*exp2$stdercondelapse) <= -1 & -1 <= (exp2$betacondelapse+1.96*exp2$stdercondelapse), 1, 0)
cr21 <- round(mean(test21),3)
cr22 <- round(mean(test22),3)
cr23 <- round(mean(test23),3)
cr24 <- round(mean(test24),3)
cr25 <- round(mean(test25),3)
theta21 <- round(mean(exp2$thetafrailgap),3)
theta22 <- round(mean(exp2$thetafrailelapse),3)
thetatest21 <- ifelse(exp2$thetapvalfrailgap <= .050,1,0) 
thetatest22 <- ifelse(exp2$thetapvalfrailelapse <= .050,1,0) 
rr21 <- round(mean(thetatest21),3)
rr22 <- round(mean(thetatest22),3)

##Acount for missing values in condition 3

beta31 <- round(mean(exp3$betafrailgap),3)
beta32 <- round(mean(exp3$betafrailelapse, na.rm=TRUE),3)
beta33 <- round(mean(exp3$betaag),3)
beta34 <- round(mean(exp3$betacondgap),3)
beta35 <- round(mean(exp3$betacondelapse),3)
sd31 <- round(sd(exp3$betafrailgap),3)
sd32 <- round(sd(exp3$betafrailelapse, na.rm=TRUE),3)
sd33 <- round(sd(exp3$betaag),3)
sd34 <- round(sd(exp3$betacondgap),3)
sd35 <- round(sd(exp3$betacondelapse),3)
se31 <- round(mean(exp3$stderfrailgap),3)
se32 <- round(mean(exp3$stderfrailelapse, na.rm=TRUE),3)
se33 <- round(mean(exp3$stderag),3)
se34 <- round(mean(exp3$stdercondgap),3)
se35 <- round(mean(exp3$stdercondelapse),3)
test31 <- ifelse((exp3$betafrailgap-1.96*exp3$stderfrailgap) <= -1 & -1 <= (exp3$betafrailgap+1.96*exp3$stderfrailgap), 1, 0)
test32 <- ifelse((exp3$betafrailelapse-1.96*exp3$stderfrailelapse) <= -1 & -1 <= (exp3$betafrailelapse+1.96*exp3$stderfrailelapse) , 1, 0)
test33 <- ifelse((exp3$betaag-1.96*exp3$stderag) <= -1 & -1 <= (exp3$betaag+1.96*exp3$stderag) , 1, 0)
test34 <- ifelse((exp3$betacondgap-1.96*exp3$stdercondgap) <= -1 & -1 <= (exp3$betacondgap+1.96*exp3$stdercondgap) , 1, 0)
test35 <- ifelse((exp3$betacondelapse-1.96*exp3$stdercondelapse) <= -1 & -1 <= (exp3$betacondelapse+1.96*exp3$stdercondelapse), 1, 0)
cr31 <- round(mean(test31),3)
cr32 <- round(mean(test32, na.rm=TRUE),3)
cr33 <- round(mean(test33),3)
cr34 <- round(mean(test34),3)
cr35 <- round(mean(test35),3)
theta31 <- round(mean(exp3$thetafrailgap),3)
theta32 <- round(mean(exp3$thetafrailelapse, na.rm=TRUE),3)
thetatest31 <- ifelse(exp3$thetapvalfrailgap <= .050,1,0) 
thetatest32 <- ifelse(exp3$thetapvalfrailelapse <= .050,1,0) 
rr31 <- round(mean(thetatest31),3)
rr32 <- round(mean(thetatest32, na.rm=TRUE),3)

@ 
\begin{table}[!tp]
\label{expmaxt50}
\caption{No Event Dependence, No Heterogeneity ($\beta=-1$, $\theta=1$)}
\begin{tabular}{lcccccc}
  \toprule
  & & & & & & \\
  Panel A & & & Standard & Coverage & & Rejection \\
  Exponential & $\hat{\beta}$ & Std Dev & Error & Rate & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta11} & \Sexpr{sd11} & \Sexpr{se11} & \Sexpr{cr11} & \Sexpr{theta11}  & \Sexpr{rr11} \\
  Frailty, elapsed &  \Sexpr{beta12} & \Sexpr{sd12} & \Sexpr{se12} & \Sexpr{cr12}   & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Andersen-Gill & \Sexpr{beta13} & \Sexpr{sd13} & \Sexpr{se13} & \Sexpr{cr13}  & & \\
  Conditional, gap & \Sexpr{beta14} & \Sexpr{sd14} & \Sexpr{se14} & \Sexpr{cr14} & &   \\
  Conditional, elapsed &  \Sexpr{beta15} & \Sexpr{sd15} & \Sexpr{se15} & \Sexpr{cr15} & &   \\
    \midrule
  & & & &  & &  \\
  Panel B & & & Standard & Coverage  & & Rejection \\
  Weibull .08 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta21} & \Sexpr{sd21} & \Sexpr{se21} & \Sexpr{cr21}  & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Frailty, elapsed &  \Sexpr{beta22} & \Sexpr{sd22} & \Sexpr{se22} & \Sexpr{cr22}     & \Sexpr{theta22}  & \Sexpr{rr22} \\
  Andersen-Gill & \Sexpr{beta23} & \Sexpr{sd23} & \Sexpr{se23} & \Sexpr{cr23}    & & \\
  Conditional, gap & \Sexpr{beta24} & \Sexpr{sd24} & \Sexpr{se24} & \Sexpr{cr24}    & & \\
  Conditional, elapsed &  \Sexpr{beta25} & \Sexpr{sd25} & \Sexpr{se25} & \Sexpr{cr25}    & & \\
    \midrule
  & & & &   & & \\
  Panel C & & & Standard & Coverage  & & Rejection \\
  Weibull 1.2 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta31} & \Sexpr{sd31} & \Sexpr{se31} & \Sexpr{cr31}   & \Sexpr{theta31}  & \Sexpr{rr31} \\
  Frailty, elapsed &  \Sexpr{beta32} & \Sexpr{sd32} & \Sexpr{se32} & \Sexpr{cr32}     & \Sexpr{theta32}  & \Sexpr{rr32} \\
  Andersen-Gill & \Sexpr{beta33} & \Sexpr{sd33} & \Sexpr{se33} & \Sexpr{cr33}    & & \\
  Conditional, gap & \Sexpr{beta34} & \Sexpr{sd34} & \Sexpr{se34} & \Sexpr{cr34}    & & \\
  Conditional, elapsed &  \Sexpr{beta35} & \Sexpr{sd35} & \Sexpr{se35} & \Sexpr{cr35}    & & \\
   & & & &   & & \\
  \bottomrule
\end{tabular}
\end{table}


<<echo=False>>=
exp1 <- read.table(file="weibull10_noed_het_maxt50.txt", header=TRUE)
exp2 <- read.table(file="weibull08_noed_het_maxt50.txt", header=TRUE)
exp3 <- read.table(file="weibull12_noed_het_maxt50.txt", header=TRUE)

mean1 <- round(mean(exp1$eventcount),3)
mean2 <- round(mean(exp2$eventcount),3)
mean3 <- round(mean(exp3$eventcount),3)

cens1 <- round(mean(exp1$censrate),3)
cens2 <- round(mean(exp2$censrate),3)
cens3 <- round(mean(exp3$censrate),3)

beta11 <- round(mean(exp1$betafrailgap),3)
beta12 <- round(mean(exp1$betafrailelapse),3)
beta13 <- round(mean(exp1$betaag),3)
beta14 <- round(mean(exp1$betacondgap),3)
beta15 <- round(mean(exp1$betacondelapse),3)

sd11 <- round(sd(exp1$betafrailgap), 3)
sd12 <- round(sd(exp1$betafrailelapse), 3)
sd13 <- round(sd(exp1$betaag), 3)
sd14 <- round(sd(exp1$betacondgap), 3)
sd15 <- round(sd(exp1$betacondelapse), 3)

se11 <- round(mean(exp1$stderfrailgap),3)
se12 <- round(mean(exp1$stderfrailelapse),3)
se13 <- round(mean(exp1$stderag),3)
se14 <- round(mean(exp1$stdercondgap),3)
se15 <- round(mean(exp1$stdercondelapse),3)

test11 <- ifelse((exp1$betafrailgap-1.96*exp1$stderfrailgap) <= -1 & -1 <= (exp1$betafrailgap+1.96*exp1$stderfrailgap), 1, 0)
test12 <- ifelse((exp1$betafrailelapse-1.96*exp1$stderfrailelapse) <= -1 & -1 <= (exp1$betafrailelapse+1.96*exp1$stderfrailelapse) , 1, 0)
test13 <- ifelse((exp1$betaag-1.96*exp1$stderag) <= -1 & -1 <= (exp1$betaag+1.96*exp1$stderag) , 1, 0)
test14 <- ifelse((exp1$betacondgap-1.96*exp1$stdercondgap) <= -1 & -1 <= (exp1$betacondgap+1.96*exp1$stdercondgap) , 1, 0)
test15 <- ifelse((exp1$betacondelapse-1.96*exp1$stdercondelapse) <= -1 & -1 <= (exp1$betacondelapse+1.96*exp1$stdercondelapse), 1, 0)
cr11 <- round(mean(test11),3)
cr12 <- round(mean(test12),3)
cr13 <- round(mean(test13),3)
cr14 <- round(mean(test14),3)
cr15 <- round(mean(test15),3)
theta11 <- round(mean(exp1$thetafrailgap),3)
theta12 <- round(mean(exp1$thetafrailelapse),3)
thetatest11 <- ifelse(exp1$thetapvalfrailgap <= .050,1,0) 
thetatest12 <- ifelse(exp1$thetapvalfrailelapse <= .050,1,0) 
rr11 <- round(mean(thetatest11),3)
rr12 <- round(mean(thetatest12),3)

beta21 <- round(mean(exp2$betafrailgap),3)
beta22 <- round(mean(exp2$betafrailelapse),3)
beta23 <- round(mean(exp2$betaag),3)
beta24 <- round(mean(exp2$betacondgap),3)
beta25 <- round(mean(exp2$betacondelapse),3)
sd21 <- round(sd(exp2$betafrailgap),3)
sd22 <- round(sd(exp2$betafrailelapse),3)
sd23 <- round(sd(exp2$betaag),3)
sd24 <- round(sd(exp2$betacondgap),3)
sd25 <- round(sd(exp2$betacondelapse),3)
se21 <- round(mean(exp2$stderfrailgap),3)
se22 <- round(mean(exp2$stderfrailelapse),3)
se23 <- round(mean(exp2$stderag),3)
se24 <- round(mean(exp2$stdercondgap),3)
se25 <- round(mean(exp2$stdercondelapse),3)
test21 <- ifelse((exp2$betafrailgap-1.96*exp2$stderfrailgap) <= -1 & -1 <= (exp2$betafrailgap+1.96*exp2$stderfrailgap), 1, 0)
test22 <- ifelse((exp2$betafrailelapse-1.96*exp2$stderfrailelapse) <= -1 & -1 <= (exp2$betafrailelapse+1.96*exp2$stderfrailelapse) , 1, 0)
test23 <- ifelse((exp2$betaag-1.96*exp2$stderag) <= -1 & -1 <= (exp2$betaag+1.96*exp2$stderag) , 1, 0)
test24 <- ifelse((exp2$betacondgap-1.96*exp2$stdercondgap) <= -1 & -1 <= (exp2$betacondgap+1.96*exp2$stdercondgap) , 1, 0)
test25 <- ifelse((exp2$betacondelapse-1.96*exp2$stdercondelapse) <= -1 & -1 <= (exp2$betacondelapse+1.96*exp2$stdercondelapse), 1, 0)
cr21 <- round(mean(test21),3)
cr22 <- round(mean(test22),3)
cr23 <- round(mean(test23),3)
cr24 <- round(mean(test24),3)
cr25 <- round(mean(test25),3)
theta21 <- round(mean(exp2$thetafrailgap),3)
theta22 <- round(mean(exp2$thetafrailelapse),3)
thetatest21 <- ifelse(exp2$thetapvalfrailgap <= .050,1,0) 
thetatest22 <- ifelse(exp2$thetapvalfrailelapse <= .050,1,0) 
rr21 <- round(mean(thetatest21),3)
rr22 <- round(mean(thetatest22),3)

##Acount for missing values in condition 3

beta31 <- round(mean(exp3$betafrailgap),3)
beta32 <- round(mean(exp3$betafrailelapse, na.rm=TRUE),3)
beta33 <- round(mean(exp3$betaag),3)
beta34 <- round(mean(exp3$betacondgap),3)
beta35 <- round(mean(exp3$betacondelapse),3)
sd31 <- round(sd(exp3$betafrailgap),3)
sd32 <- round(sd(exp3$betafrailelapse, na.rm=TRUE),3)
sd33 <- round(sd(exp3$betaag),3)
sd34 <- round(sd(exp3$betacondgap),3)
sd35 <- round(sd(exp3$betacondelapse),3)
se31 <- round(mean(exp3$stderfrailgap),3)
se32 <- round(mean(exp3$stderfrailelapse, na.rm=TRUE),3)
se33 <- round(mean(exp3$stderag),3)
se34 <- round(mean(exp3$stdercondgap),3)
se35 <- round(mean(exp3$stdercondelapse),3)
test31 <- ifelse((exp3$betafrailgap-1.96*exp3$stderfrailgap) <= -1 & -1 <= (exp3$betafrailgap+1.96*exp3$stderfrailgap), 1, 0)
test32 <- ifelse((exp3$betafrailelapse-1.96*exp3$stderfrailelapse) <= -1 & -1 <= (exp3$betafrailelapse+1.96*exp3$stderfrailelapse) , 1, 0)
test33 <- ifelse((exp3$betaag-1.96*exp3$stderag) <= -1 & -1 <= (exp3$betaag+1.96*exp3$stderag) , 1, 0)
test34 <- ifelse((exp3$betacondgap-1.96*exp3$stdercondgap) <= -1 & -1 <= (exp3$betacondgap+1.96*exp3$stdercondgap) , 1, 0)
test35 <- ifelse((exp3$betacondelapse-1.96*exp3$stdercondelapse) <= -1 & -1 <= (exp3$betacondelapse+1.96*exp3$stdercondelapse), 1, 0)
cr31 <- round(mean(test31),3)
cr32 <- round(mean(test32, na.rm=TRUE),3)
cr33 <- round(mean(test33),3)
cr34 <- round(mean(test34),3)
cr35 <- round(mean(test35),3)
theta31 <- round(mean(exp3$thetafrailgap),3)
theta32 <- round(mean(exp3$thetafrailelapse, na.rm=TRUE),3)
thetatest31 <- ifelse(exp3$thetapvalfrailgap <= .050,1,0) 
thetatest32 <- ifelse(exp3$thetapvalfrailelapse <= .050,1,0) 
rr31 <- round(mean(thetatest31),3)
rr32 <- round(mean(thetatest32, na.rm=TRUE),3)

@ 
\begin{table}[!tp]
\label{expmaxt50}
\caption{No Event Dependence, Heterogeneity ($\beta=-1$, $\theta=1$)}
\begin{tabular}{lcccccc}
  \toprule
  & & & & & & \\
  Panel A & & & Standard & Coverage & & Rejection \\
  Exponential & $\hat{\beta}$ & Std Dev & Error & Rate & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta11} & \Sexpr{sd11} & \Sexpr{se11} & \Sexpr{cr11} & \Sexpr{theta11}  & \Sexpr{rr11} \\
  Frailty, elapsed &  \Sexpr{beta12} & \Sexpr{sd12} & \Sexpr{se12} & \Sexpr{cr12}   & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Andersen-Gill & \Sexpr{beta13} & \Sexpr{sd13} & \Sexpr{se13} & \Sexpr{cr13}  & & \\
  Conditional, gap & \Sexpr{beta14} & \Sexpr{sd14} & \Sexpr{se14} & \Sexpr{cr14} & &   \\
  Conditional, elapsed &  \Sexpr{beta15} & \Sexpr{sd15} & \Sexpr{se15} & \Sexpr{cr15} & &   \\
    \midrule
  & & & &  & &  \\
  Panel B & & & Standard & Coverage  & & Rejection \\
  Weibull .08 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta21} & \Sexpr{sd21} & \Sexpr{se21} & \Sexpr{cr21}  & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Frailty, elapsed &  \Sexpr{beta22} & \Sexpr{sd22} & \Sexpr{se22} & \Sexpr{cr22}     & \Sexpr{theta22}  & \Sexpr{rr22} \\
  Andersen-Gill & \Sexpr{beta23} & \Sexpr{sd23} & \Sexpr{se23} & \Sexpr{cr23}    & & \\
  Conditional, gap & \Sexpr{beta24} & \Sexpr{sd24} & \Sexpr{se24} & \Sexpr{cr24}    & & \\
  Conditional, elapsed &  \Sexpr{beta25} & \Sexpr{sd25} & \Sexpr{se25} & \Sexpr{cr25}    & & \\
    \midrule
  & & & &   & & \\
  Panel C & & & Standard & Coverage  & & Rejection \\
  Weibull 1.2 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta31} & \Sexpr{sd31} & \Sexpr{se31} & \Sexpr{cr31}   & \Sexpr{theta31}  & \Sexpr{rr31} \\
  Frailty, elapsed &  \Sexpr{beta32} & \Sexpr{sd32} & \Sexpr{se32} & \Sexpr{cr32}     & \Sexpr{theta32}  & \Sexpr{rr32} \\
  Andersen-Gill & \Sexpr{beta33} & \Sexpr{sd33} & \Sexpr{se33} & \Sexpr{cr33}    & & \\
  Conditional, gap & \Sexpr{beta34} & \Sexpr{sd34} & \Sexpr{se34} & \Sexpr{cr34}    & & \\
  Conditional, elapsed &  \Sexpr{beta35} & \Sexpr{sd35} & \Sexpr{se35} & \Sexpr{cr35}    & & \\
   & & & &   & & \\
  \bottomrule
\end{tabular}
\end{table}



<<echo=False>>=
exp1 <- read.table(file="weibull10_ed_nohet_maxt50.txt", header=TRUE)
exp2 <- read.table(file="weibull08_ed_nohet_maxt50.txt", header=TRUE)
exp3 <- read.table(file="weibull12_ed_nohet_maxt50.txt", header=TRUE)

mean1 <- round(mean(exp1$eventcount),3)
mean2 <- round(mean(exp2$eventcount),3)
mean3 <- round(mean(exp3$eventcount),3)

cens1 <- round(mean(exp1$censrate),3)
cens2 <- round(mean(exp2$censrate),3)
cens3 <- round(mean(exp3$censrate),3)

beta11 <- round(mean(exp1$betafrailgap),3)
beta12 <- round(mean(exp1$betafrailelapse),3)
beta13 <- round(mean(exp1$betaag),3)
beta14 <- round(mean(exp1$betacondgap),3)
beta15 <- round(mean(exp1$betacondelapse),3)

sd11 <- round(sd(exp1$betafrailgap), 3)
sd12 <- round(sd(exp1$betafrailelapse), 3)
sd13 <- round(sd(exp1$betaag), 3)
sd14 <- round(sd(exp1$betacondgap), 3)
sd15 <- round(sd(exp1$betacondelapse), 3)

se11 <- round(mean(exp1$stderfrailgap),3)
se12 <- round(mean(exp1$stderfrailelapse),3)
se13 <- round(mean(exp1$stderag),3)
se14 <- round(mean(exp1$stdercondgap),3)
se15 <- round(mean(exp1$stdercondelapse),3)

test11 <- ifelse((exp1$betafrailgap-1.96*exp1$stderfrailgap) <= -1 & -1 <= (exp1$betafrailgap+1.96*exp1$stderfrailgap), 1, 0)
test12 <- ifelse((exp1$betafrailelapse-1.96*exp1$stderfrailelapse) <= -1 & -1 <= (exp1$betafrailelapse+1.96*exp1$stderfrailelapse) , 1, 0)
test13 <- ifelse((exp1$betaag-1.96*exp1$stderag) <= -1 & -1 <= (exp1$betaag+1.96*exp1$stderag) , 1, 0)
test14 <- ifelse((exp1$betacondgap-1.96*exp1$stdercondgap) <= -1 & -1 <= (exp1$betacondgap+1.96*exp1$stdercondgap) , 1, 0)
test15 <- ifelse((exp1$betacondelapse-1.96*exp1$stdercondelapse) <= -1 & -1 <= (exp1$betacondelapse+1.96*exp1$stdercondelapse), 1, 0)
cr11 <- round(mean(test11),3)
cr12 <- round(mean(test12),3)
cr13 <- round(mean(test13),3)
cr14 <- round(mean(test14),3)
cr15 <- round(mean(test15),3)
theta11 <- round(mean(exp1$thetafrailgap),3)
theta12 <- round(mean(exp1$thetafrailelapse),3)
thetatest11 <- ifelse(exp1$thetapvalfrailgap <= .050,1,0) 
thetatest12 <- ifelse(exp1$thetapvalfrailelapse <= .050,1,0) 
rr11 <- round(mean(thetatest11),3)
rr12 <- round(mean(thetatest12),3)

beta21 <- round(mean(exp2$betafrailgap),3)
beta22 <- round(mean(exp2$betafrailelapse),3)
beta23 <- round(mean(exp2$betaag),3)
beta24 <- round(mean(exp2$betacondgap),3)
beta25 <- round(mean(exp2$betacondelapse),3)
sd21 <- round(sd(exp2$betafrailgap),3)
sd22 <- round(sd(exp2$betafrailelapse),3)
sd23 <- round(sd(exp2$betaag),3)
sd24 <- round(sd(exp2$betacondgap),3)
sd25 <- round(sd(exp2$betacondelapse),3)
se21 <- round(mean(exp2$stderfrailgap),3)
se22 <- round(mean(exp2$stderfrailelapse),3)
se23 <- round(mean(exp2$stderag),3)
se24 <- round(mean(exp2$stdercondgap),3)
se25 <- round(mean(exp2$stdercondelapse),3)
test21 <- ifelse((exp2$betafrailgap-1.96*exp2$stderfrailgap) <= -1 & -1 <= (exp2$betafrailgap+1.96*exp2$stderfrailgap), 1, 0)
test22 <- ifelse((exp2$betafrailelapse-1.96*exp2$stderfrailelapse) <= -1 & -1 <= (exp2$betafrailelapse+1.96*exp2$stderfrailelapse) , 1, 0)
test23 <- ifelse((exp2$betaag-1.96*exp2$stderag) <= -1 & -1 <= (exp2$betaag+1.96*exp2$stderag) , 1, 0)
test24 <- ifelse((exp2$betacondgap-1.96*exp2$stdercondgap) <= -1 & -1 <= (exp2$betacondgap+1.96*exp2$stdercondgap) , 1, 0)
test25 <- ifelse((exp2$betacondelapse-1.96*exp2$stdercondelapse) <= -1 & -1 <= (exp2$betacondelapse+1.96*exp2$stdercondelapse), 1, 0)
cr21 <- round(mean(test21),3)
cr22 <- round(mean(test22),3)
cr23 <- round(mean(test23),3)
cr24 <- round(mean(test24),3)
cr25 <- round(mean(test25),3)
theta21 <- round(mean(exp2$thetafrailgap),3)
theta22 <- round(mean(exp2$thetafrailelapse),3)
thetatest21 <- ifelse(exp2$thetapvalfrailgap <= .050,1,0) 
thetatest22 <- ifelse(exp2$thetapvalfrailelapse <= .050,1,0) 
rr21 <- round(mean(thetatest21),3)
rr22 <- round(mean(thetatest22),3)

##Acount for missing values in condition 3

beta31 <- round(mean(exp3$betafrailgap),3)
beta32 <- round(mean(exp3$betafrailelapse, na.rm=TRUE),3)
beta33 <- round(mean(exp3$betaag),3)
beta34 <- round(mean(exp3$betacondgap),3)
beta35 <- round(mean(exp3$betacondelapse),3)
sd31 <- round(sd(exp3$betafrailgap),3)
sd32 <- round(sd(exp3$betafrailelapse, na.rm=TRUE),3)
sd33 <- round(sd(exp3$betaag),3)
sd34 <- round(sd(exp3$betacondgap),3)
sd35 <- round(sd(exp3$betacondelapse),3)
se31 <- round(mean(exp3$stderfrailgap),3)
se32 <- round(mean(exp3$stderfrailelapse, na.rm=TRUE),3)
se33 <- round(mean(exp3$stderag),3)
se34 <- round(mean(exp3$stdercondgap),3)
se35 <- round(mean(exp3$stdercondelapse),3)
test31 <- ifelse((exp3$betafrailgap-1.96*exp3$stderfrailgap) <= -1 & -1 <= (exp3$betafrailgap+1.96*exp3$stderfrailgap), 1, 0)
test32 <- ifelse((exp3$betafrailelapse-1.96*exp3$stderfrailelapse) <= -1 & -1 <= (exp3$betafrailelapse+1.96*exp3$stderfrailelapse) , 1, 0)
test33 <- ifelse((exp3$betaag-1.96*exp3$stderag) <= -1 & -1 <= (exp3$betaag+1.96*exp3$stderag) , 1, 0)
test34 <- ifelse((exp3$betacondgap-1.96*exp3$stdercondgap) <= -1 & -1 <= (exp3$betacondgap+1.96*exp3$stdercondgap) , 1, 0)
test35 <- ifelse((exp3$betacondelapse-1.96*exp3$stdercondelapse) <= -1 & -1 <= (exp3$betacondelapse+1.96*exp3$stdercondelapse), 1, 0)
cr31 <- round(mean(test31),3)
cr32 <- round(mean(test32, na.rm=TRUE),3)
cr33 <- round(mean(test33),3)
cr34 <- round(mean(test34),3)
cr35 <- round(mean(test35),3)
theta31 <- round(mean(exp3$thetafrailgap),3)
theta32 <- round(mean(exp3$thetafrailelapse, na.rm=TRUE),3)
thetatest31 <- ifelse(exp3$thetapvalfrailgap <= .050,1,0) 
thetatest32 <- ifelse(exp3$thetapvalfrailelapse <= .050,1,0) 
rr31 <- round(mean(thetatest31),3)
rr32 <- round(mean(thetatest32, na.rm=TRUE),3)

@ 
\begin{table}[!tp]
\label{expmaxt50}
\caption{Event Dependence, No Heterogeneity ($\beta=-1$, $\theta=1$)}
\begin{tabular}{lcccccc}
  \toprule
  & & & & & & \\
  Panel A & & & Standard & Coverage & & Rejection \\
  Exponential & $\hat{\beta}$ & Std Dev & Error & Rate & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta11} & \Sexpr{sd11} & \Sexpr{se11} & \Sexpr{cr11} & \Sexpr{theta11}  & \Sexpr{rr11} \\
  Frailty, elapsed &  \Sexpr{beta12} & \Sexpr{sd12} & \Sexpr{se12} & \Sexpr{cr12}   & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Andersen-Gill & \Sexpr{beta13} & \Sexpr{sd13} & \Sexpr{se13} & \Sexpr{cr13}  & & \\
  Conditional, gap & \Sexpr{beta14} & \Sexpr{sd14} & \Sexpr{se14} & \Sexpr{cr14} & &   \\
  Conditional, elapsed &  \Sexpr{beta15} & \Sexpr{sd15} & \Sexpr{se15} & \Sexpr{cr15} & &   \\
    \midrule
  & & & &  & &  \\
  Panel B & & & Standard & Coverage  & & Rejection \\
  Weibull .08 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta21} & \Sexpr{sd21} & \Sexpr{se21} & \Sexpr{cr21}  & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Frailty, elapsed &  \Sexpr{beta22} & \Sexpr{sd22} & \Sexpr{se22} & \Sexpr{cr22}     & \Sexpr{theta22}  & \Sexpr{rr22} \\
  Andersen-Gill & \Sexpr{beta23} & \Sexpr{sd23} & \Sexpr{se23} & \Sexpr{cr23}    & & \\
  Conditional, gap & \Sexpr{beta24} & \Sexpr{sd24} & \Sexpr{se24} & \Sexpr{cr24}    & & \\
  Conditional, elapsed &  \Sexpr{beta25} & \Sexpr{sd25} & \Sexpr{se25} & \Sexpr{cr25}    & & \\
    \midrule
  & & & &   & & \\
  Panel C & & & Standard & Coverage  & & Rejection \\
  Weibull 1.2 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta31} & \Sexpr{sd31} & \Sexpr{se31} & \Sexpr{cr31}   & \Sexpr{theta31}  & \Sexpr{rr31} \\
  Frailty, elapsed &  \Sexpr{beta32} & \Sexpr{sd32} & \Sexpr{se32} & \Sexpr{cr32}     & \Sexpr{theta32}  & \Sexpr{rr32} \\
  Andersen-Gill & \Sexpr{beta33} & \Sexpr{sd33} & \Sexpr{se33} & \Sexpr{cr33}    & & \\
  Conditional, gap & \Sexpr{beta34} & \Sexpr{sd34} & \Sexpr{se34} & \Sexpr{cr34}    & & \\
  Conditional, elapsed &  \Sexpr{beta35} & \Sexpr{sd35} & \Sexpr{se35} & \Sexpr{cr35}    & & \\
   & & & &   & & \\
  \bottomrule
\end{tabular}
\end{table}


<<echo=False>>=
exp1 <- read.table(file="weibull10_ed_het_maxt50.txt", header=TRUE)
exp2 <- read.table(file="weibull08_ed_het_maxt50.txt", header=TRUE)
exp3 <- read.table(file="weibull12_ed_het_maxt50.txt", header=TRUE)

mean1 <- round(mean(exp1$eventcount),3)
mean2 <- round(mean(exp2$eventcount),3)
mean3 <- round(mean(exp3$eventcount),3)

cens1 <- round(mean(exp1$censrate),3)
cens2 <- round(mean(exp2$censrate),3)
cens3 <- round(mean(exp3$censrate),3)

beta11 <- round(mean(exp1$betafrailgap),3)
beta12 <- round(mean(exp1$betafrailelapse, na.rm=TRUE),3)
beta13 <- round(mean(exp1$betaag),3)
beta14 <- round(mean(exp1$betacondgap),3)
beta15 <- round(mean(exp1$betacondelapse),3)

sd11 <- round(sd(exp1$betafrailgap), 3)
sd12 <- round(sd(exp1$betafrailelapse, na.rm=TRUE), 3)
sd13 <- round(sd(exp1$betaag), 3)
sd14 <- round(sd(exp1$betacondgap), 3)
sd15 <- round(sd(exp1$betacondelapse), 3)

se11 <- round(mean(exp1$stderfrailgap),3)
se12 <- round(mean(exp1$stderfrailelapse, na.rm=TRUE),3)
se13 <- round(mean(exp1$stderag),3)
se14 <- round(mean(exp1$stdercondgap),3)
se15 <- round(mean(exp1$stdercondelapse),3)

test11 <- ifelse((exp1$betafrailgap-1.96*exp1$stderfrailgap) <= -1 & -1 <= (exp1$betafrailgap+1.96*exp1$stderfrailgap), 1, 0)
test12 <- ifelse((exp1$betafrailelapse-1.96*exp1$stderfrailelapse) <= -1 & -1 <= (exp1$betafrailelapse+1.96*exp1$stderfrailelapse) , 1, 0)
test13 <- ifelse((exp1$betaag-1.96*exp1$stderag) <= -1 & -1 <= (exp1$betaag+1.96*exp1$stderag) , 1, 0)
test14 <- ifelse((exp1$betacondgap-1.96*exp1$stdercondgap) <= -1 & -1 <= (exp1$betacondgap+1.96*exp1$stdercondgap) , 1, 0)
test15 <- ifelse((exp1$betacondelapse-1.96*exp1$stdercondelapse) <= -1 & -1 <= (exp1$betacondelapse+1.96*exp1$stdercondelapse), 1, 0)
cr11 <- round(mean(test11),3)
cr12 <- round(mean(test12, na.rm=TRUE),3)
cr13 <- round(mean(test13),3)
cr14 <- round(mean(test14),3)
cr15 <- round(mean(test15),3)
theta11 <- round(mean(exp1$thetafrailgap),3)
theta12 <- round(mean(exp1$thetafrailelapse, na.rm=TRUE),3)
thetatest11 <- ifelse(exp1$thetapvalfrailgap <= .050,1,0) 
thetatest12 <- ifelse(exp1$thetapvalfrailelapse <= .050,1,0) 
rr11 <- round(mean(thetatest11),3)
rr12 <- round(mean(thetatest12, na.rm=TRUE),3)

beta21 <- round(mean(exp2$betafrailgap),3)
beta22 <- round(mean(exp2$betafrailelapse, na.rm=TRUE),3)
beta23 <- round(mean(exp2$betaag),3)
beta24 <- round(mean(exp2$betacondgap),3)
beta25 <- round(mean(exp2$betacondelapse),3)
sd21 <- round(sd(exp2$betafrailgap),3)
sd22 <- round(sd(exp2$betafrailelapse, na.rm=TRUE),3)
sd23 <- round(sd(exp2$betaag),3)
sd24 <- round(sd(exp2$betacondgap),3)
sd25 <- round(sd(exp2$betacondelapse),3)
se21 <- round(mean(exp2$stderfrailgap),3)
se22 <- round(mean(exp2$stderfrailelapse, na.rm=TRUE),3)
se23 <- round(mean(exp2$stderag),3)
se24 <- round(mean(exp2$stdercondgap),3)
se25 <- round(mean(exp2$stdercondelapse),3)
test21 <- ifelse((exp2$betafrailgap-1.96*exp2$stderfrailgap) <= -1 & -1 <= (exp2$betafrailgap+1.96*exp2$stderfrailgap), 1, 0)
test22 <- ifelse((exp2$betafrailelapse-1.96*exp2$stderfrailelapse) <= -1 & -1 <= (exp2$betafrailelapse+1.96*exp2$stderfrailelapse) , 1, 0)
test23 <- ifelse((exp2$betaag-1.96*exp2$stderag) <= -1 & -1 <= (exp2$betaag+1.96*exp2$stderag) , 1, 0)
test24 <- ifelse((exp2$betacondgap-1.96*exp2$stdercondgap) <= -1 & -1 <= (exp2$betacondgap+1.96*exp2$stdercondgap) , 1, 0)
test25 <- ifelse((exp2$betacondelapse-1.96*exp2$stdercondelapse) <= -1 & -1 <= (exp2$betacondelapse+1.96*exp2$stdercondelapse), 1, 0)
cr21 <- round(mean(test21),3)
cr22 <- round(mean(test22, na.rm=TRUE),3)
cr23 <- round(mean(test23),3)
cr24 <- round(mean(test24),3)
cr25 <- round(mean(test25),3)
theta21 <- round(mean(exp2$thetafrailgap),3)
theta22 <- round(mean(exp2$thetafrailelapse, na.rm=TRUE),3)
thetatest21 <- ifelse(exp2$thetapvalfrailgap <= .050,1,0) 
thetatest22 <- ifelse(exp2$thetapvalfrailelapse <= .050,1,0) 
rr21 <- round(mean(thetatest21),3)
rr22 <- round(mean(thetatest22, na.rm=TRUE),3)

##Acount for missing values in condition 3

beta31 <- round(mean(exp3$betafrailgap),3)
beta32 <- round(mean(exp3$betafrailelapse, na.rm=TRUE),3)
beta33 <- round(mean(exp3$betaag),3)
beta34 <- round(mean(exp3$betacondgap),3)
beta35 <- round(mean(exp3$betacondelapse),3)
sd31 <- round(sd(exp3$betafrailgap),3)
sd32 <- round(sd(exp3$betafrailelapse, na.rm=TRUE),3)
sd33 <- round(sd(exp3$betaag),3)
sd34 <- round(sd(exp3$betacondgap),3)
sd35 <- round(sd(exp3$betacondelapse),3)
se31 <- round(mean(exp3$stderfrailgap),3)
se32 <- round(mean(exp3$stderfrailelapse, na.rm=TRUE),3)
se33 <- round(mean(exp3$stderag),3)
se34 <- round(mean(exp3$stdercondgap),3)
se35 <- round(mean(exp3$stdercondelapse),3)
test31 <- ifelse((exp3$betafrailgap-1.96*exp3$stderfrailgap) <= -1 & -1 <= (exp3$betafrailgap+1.96*exp3$stderfrailgap), 1, 0)
test32 <- ifelse((exp3$betafrailelapse-1.96*exp3$stderfrailelapse) <= -1 & -1 <= (exp3$betafrailelapse+1.96*exp3$stderfrailelapse) , 1, 0)
test33 <- ifelse((exp3$betaag-1.96*exp3$stderag) <= -1 & -1 <= (exp3$betaag+1.96*exp3$stderag) , 1, 0)
test34 <- ifelse((exp3$betacondgap-1.96*exp3$stdercondgap) <= -1 & -1 <= (exp3$betacondgap+1.96*exp3$stdercondgap) , 1, 0)
test35 <- ifelse((exp3$betacondelapse-1.96*exp3$stdercondelapse) <= -1 & -1 <= (exp3$betacondelapse+1.96*exp3$stdercondelapse), 1, 0)
cr31 <- round(mean(test31),3)
cr32 <- round(mean(test32, na.rm=TRUE),3)
cr33 <- round(mean(test33),3)
cr34 <- round(mean(test34),3)
cr35 <- round(mean(test35),3)
theta31 <- round(mean(exp3$thetafrailgap),3)
theta32 <- round(mean(exp3$thetafrailelapse, na.rm=TRUE),3)
thetatest31 <- ifelse(exp3$thetapvalfrailgap <= .050,1,0) 
thetatest32 <- ifelse(exp3$thetapvalfrailelapse <= .050,1,0) 
rr31 <- round(mean(thetatest31),3)
rr32 <- round(mean(thetatest32, na.rm=TRUE),3)

@ 
\begin{table}[!tp]
\label{expmaxt50}
\caption{Event Dependence, Heterogeneity ($\beta=-1$, $\theta=1$)}
\begin{tabular}{lcccccc}
  \toprule
  & & & & & & \\
  Panel A & & & Standard & Coverage & & Rejection \\
  Exponential & $\hat{\beta}$ & Std Dev & Error & Rate & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta11} & \Sexpr{sd11} & \Sexpr{se11} & \Sexpr{cr11} & \Sexpr{theta11}  & \Sexpr{rr11} \\
  Frailty, elapsed &  \Sexpr{beta12} & \Sexpr{sd12} & \Sexpr{se12} & \Sexpr{cr12}   & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Andersen-Gill & \Sexpr{beta13} & \Sexpr{sd13} & \Sexpr{se13} & \Sexpr{cr13}  & & \\
  Conditional, gap & \Sexpr{beta14} & \Sexpr{sd14} & \Sexpr{se14} & \Sexpr{cr14} & &   \\
  Conditional, elapsed &  \Sexpr{beta15} & \Sexpr{sd15} & \Sexpr{se15} & \Sexpr{cr15} & &   \\
    \midrule
  & & & &  & &  \\
  Panel B & & & Standard & Coverage  & & Rejection \\
  Weibull .08 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta21} & \Sexpr{sd21} & \Sexpr{se21} & \Sexpr{cr21}  & \Sexpr{theta21}  & \Sexpr{rr21} \\
  Frailty, elapsed &  \Sexpr{beta22} & \Sexpr{sd22} & \Sexpr{se22} & \Sexpr{cr22}     & \Sexpr{theta22}  & \Sexpr{rr22} \\
  Andersen-Gill & \Sexpr{beta23} & \Sexpr{sd23} & \Sexpr{se23} & \Sexpr{cr23}    & & \\
  Conditional, gap & \Sexpr{beta24} & \Sexpr{sd24} & \Sexpr{se24} & \Sexpr{cr24}    & & \\
  Conditional, elapsed &  \Sexpr{beta25} & \Sexpr{sd25} & \Sexpr{se25} & \Sexpr{cr25}    & & \\
    \midrule
  & & & &   & & \\
  Panel C & & & Standard & Coverage  & & Rejection \\
  Weibull 1.2 & $\hat{\beta}$ & Std Dev & Error & Rate  & $\hat{\theta}$ & Rate \\
  \midrule
  Conditional Frailty, gap & \Sexpr{beta31} & \Sexpr{sd31} & \Sexpr{se31} & \Sexpr{cr31}   & \Sexpr{theta31}  & \Sexpr{rr31} \\
  Frailty, elapsed &  \Sexpr{beta32} & \Sexpr{sd32} & \Sexpr{se32} & \Sexpr{cr32}     & \Sexpr{theta32}  & \Sexpr{rr32} \\
  Andersen-Gill & \Sexpr{beta33} & \Sexpr{sd33} & \Sexpr{se33} & \Sexpr{cr33}    & & \\
  Conditional, gap & \Sexpr{beta34} & \Sexpr{sd34} & \Sexpr{se34} & \Sexpr{cr34}    & & \\
  Conditional, elapsed &  \Sexpr{beta35} & \Sexpr{sd35} & \Sexpr{se35} & \Sexpr{cr35}    & & \\
   & & & &   & & \\
  \bottomrule
\end{tabular}
\end{table}


\end{document}
